package bz.ziro.kanbe.controller.file;

import java.util.Date;
import java.util.logging.Logger;
import org.slim3.controller.Navigation;
import org.slim3.util.BeanUtil;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

import bz.ziro.kanbe.dao.SiteFileDao;
import bz.ziro.kanbe.model.SiteFile;

/**
 * ファイル更新処理
 * @author Administrator
 */
public class UpdateController extends FileUploadController {

    @SuppressWarnings("unused")
    private static final Logger logger = Logger.getLogger(UpdateController.class.getName());

    @Override
    public Navigation runFileUpload() {

        String keyBuf = requestScope("fileKey");
        //データを検索
        SiteFile file = SiteFileDao.find(Long.valueOf(keyBuf));
 
        BeanUtil.copy(request, file);
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        //編集日を設定
        file.setEditDate(new Date());
        file.setEditor(user);

        //ファイルデータの設定
        setFileData(file);
        
        return null;
    }

}
